/*
 * Copyright (c) 2014 . All Rights Reserved.
 */
package com.cgmnx.admin.dao.mapper.rbac;

import com.cgmnx.admin.common.bean.Limiter;
import com.cgmnx.admin.common.enums.ValidEnumType;
import com.cgmnx.admin.dao.entity.rbac.ResourceEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 资源管理
 *
 * @author: Date: 14-3-1 Time: 下午3:59
 * @version: \$Id$
 */
@Repository
public interface ResourceMapper {

    /**
     * 保存权限管理
     *
     * @param entity
     * @return
     */
    int save(ResourceEntity entity);

    /**
     * 批量保存权限
     *
     * @param entityList
     * @return
     */
    int saveAll(@Param("entityList") List<ResourceEntity> entityList);

    /**
     * @param id
     * @return
     */
    ResourceEntity queryById(@Param("id") Integer id);

    /**
     * 更新资源
     *
     * @param entity
     * @return
     */
    int update(ResourceEntity entity);

    /**
     * 根据id来查找它所有子资源
     *
     * @param parentId
     * @return
     */
    List<ResourceEntity> queryByParentId(@Param("parentId") int parentId);

    /**
     * 根据uri查询对应的资源
     *
     * @return
     */
    Integer queryByUri(@Param("uri") String uri);

    /**
     * 批量删除
     *
     * @param idList
     * @return
     */
    Integer updateStatus(@Param("idList") List<Integer> idList, @Param("validStatus") ValidEnumType validStatus);

    List<ResourceEntity> queryPage(@Param("searchName") String searchName, @Param("limiter") Limiter limiter);

    Integer count(@Param("searchName") String searchName);

    List<ResourceEntity> queryByRoleId(@Param("roleId") Integer roleId);

    List<ResourceEntity> queryByUserId(@Param("userId") String userId);

    void updateNodeCountIncr(@Param("id") Integer id);

    void updateNodeCountDecr(@Param("id") Integer id);

    List<ResourceEntity> queryAll();

    List<ResourceEntity> queryList(@Param("resourceIdList") List<Integer> resourceIdList);
}